<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:c="http://xmlns.jcp.org/jsf/composite"
	xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/jsp/WEB/pageLayout.xhtml">

	<ui:define name="centro">
		<h:form id="form">
			<p:growl id="msgs" showDetail="true" />

			<p:panel id="localizar" header="Localizar Estabelecimento" toggleable="true"
				toggleSpeed="500" collapsed="true" widgetVar="panel"
				style="margin-bottom:20px">
				<h:panelGrid id="gridEstabelecimentos" columns="5" style="border:0px">
					<p:selectOneMenu value="#{CadEstabelecimentoBean.tpConsulta}">
						<f:selectItem itemLabel="Razão Social" itemValue="1" />
						<f:selectItem itemLabel="Código" itemValue="2" />
					</p:selectOneMenu>

					<p:inputText id="nomes" value="#{CadEstabelecimentoBean.textoConsulta}" />

					<p:commandButton id="searchButton" image="ui-icon-search"
						update="@cadEstabelecimentos" ajax="false" title="Consultar Estabelecimentos"
						actionListener="#{CadEstabelecimentoBean.consultarEstabelecimento}" />
				</h:panelGrid>
			</p:panel>

			<p:panel id="Cadastrar" header="Cadastrar Estabelecimento">

				<br />
				<h:panelGrid id="cadEstabelecimentos" columns="2" cellspacing="3"
					value="#{CadEstabelecimentoBean.listaEstabelecimento}" 
					rowIndexVar="rowIndex">

					<h:outputLabel for="razaoSocial" value="Razão Social : " />
					<p:inputText id="razaoSocial" label="RazaoSocial" immediate="true"
						value="#{CadEstabelecimentoBean.estabelecimento.razaoSocial}" />

					<h:outputLabel for="cnpj" value="CNPJ : " />
					<p:inputText id="cnpj" label="Cnpj"
						requiredMessage="Preencha o campo CNPJ"
						value="#{CadEstabelecimentoBean.estabelecimento.cnpj}" />

					<h:outputLabel for="inscrEst" value="Inscr. Est. : " />
					<p:inputText id="inscrEst" label ="InscricaoEstadual" 
						value="#{CadEstabelecimentoBean.estabelecimento.inscricaoEstadual}"  />
						
					<h:outputLabel for="endereco" value="Endereço : " />
					<p:inputText id="endereco" label="Endereco"
						value="#{CadEstabelecimentoBean.estabelecimento.endereco}" />
						
					<h:outputLabel for="bairro" value="Bairro : " />
					<p:inputText id="bairro" label="Bairro"
						value="#{CadEstabelecimentoBean.estabelecimento.bairro}" />
						
					<h:outputLabel for="cep" value="CEP : " />
					<p:inputText id="cep" label="Cep"
						value="#{CadEstabelecimentoBean.estabelecimento.cep}" />
						
					<h:outputLabel for="cidade" value="Cidade : " />
					<p:inputText id="cidade" label="Cidade"
						value="#{CadEstabelecimentoBean.estabelecimento.cidade}" />
						
					<p:outputLabel for="uf" value="UF : " />
						<p:selectOneMenu id="uf" value="#{CadEstabelecimentoBean.estabelecimento.uf}" style="width:55px">
							<f:selectItem itemLabel=" " itemValue="" />
							<f:selectItem itemLabel="AC" itemValue="AC" />
            				<f:selectItem itemLabel="AL" itemValue="AL" />
            				<f:selectItem itemLabel="AM" itemValue="AM" />
            				<f:selectItem itemLabel="AP" itemValue="AP" />
            				<f:selectItem itemLabel="BA" itemValue="BA" />
            				<f:selectItem itemLabel="CE" itemValue="CE" />
            				<f:selectItem itemLabel="DF" itemValue="DF" />
            				<f:selectItem itemLabel="ES" itemValue="ES" />
            				<f:selectItem itemLabel="GO" itemValue="GO" />
            				<f:selectItem itemLabel="MA" itemValue="MA" />
            				<f:selectItem itemLabel="MG" itemValue="MG" />
            				<f:selectItem itemLabel="MT" itemValue="MT" />
            				<f:selectItem itemLabel="MS" itemValue="MS" />
            				<f:selectItem itemLabel="PA" itemValue="PA" />
            				<f:selectItem itemLabel="PB" itemValue="PB" />
            				<f:selectItem itemLabel="PE" itemValue="PE" />
            				<f:selectItem itemLabel="PR" itemValue="PR" />
            				<f:selectItem itemLabel="PI" itemValue="PI" />
            				<f:selectItem itemLabel="RJ" itemValue="RJ" />
            				<f:selectItem itemLabel="RN" itemValue="RN" />
            				<f:selectItem itemLabel="RO" itemValue="RO" />
            				<f:selectItem itemLabel="RS" itemValue="RS" />
            				<f:selectItem itemLabel="RR" itemValue="RR" />
            				<f:selectItem itemLabel="SC" itemValue="SC" />
            				<f:selectItem itemLabel="SE" itemValue="SE" />
            				<f:selectItem itemLabel="SP" itemValue="SP" />
            				<f:selectItem itemLabel="TO" itemValue="TO" />
						
						</p:selectOneMenu>
											
					<h:outputLabel for="contato" value="Nome contato : " />
					<p:inputText id="contato" label="Contato"
						value="#{CadEstabelecimentoBean.estabelecimento.nomeContato}" />
						
					<h:outputLabel for="tel" value="Telefone (coml) : " />
					<p:inputText id="tel" label="Tel"
						value="#{CadEstabelecimentoBean.estabelecimento.telefone}" />
						
					<h:outputLabel for="cel" value="Celular : " />
					<p:inputText id="cel" label="Cel"
						value="#{CadEstabelecimentoBean.estabelecimento.celular}" />								
						
					<h:outputLabel for="email" value="E-mail : " />
					<p:inputText id="email" label="Email"
						value="#{CadEstabelecimentoBean.estabelecimento.email}" />	

					<h:outputLabel for="site" value="Site : " />
					<p:inputText id="site" label="Site" 
						value="#{CadEstabelecimentoBean.estabelecimento.site}"  />

					<br />
				</h:panelGrid>

				<p:separator />

				<p:commandButton id="salvar" value="Salvar" update="form"
					icon="ui-icon-plusthick" actionListener="#{CadEstabelecimentoBean.salvar}"
					ajax="false" resetValues="true" />

				<p:commandButton id="atualizar" value="Atualizar" update="@all"
					icon="ui-icon-disk" ajax="false"
					actionListener="#{CadEstabelecimentoBean.atualizar}" />

				<p:commandButton id="excluir" value="Excluir"
					onclick="confirmaExclusao.show()" icon="ui-icon-minus" />

				<p:commandButton id="limpar" value="Limpar" update="@form"
					action="#{CadEstabelecimentoBean.refresh()}" icon="ui-icon-document"
					resetValues="true" />
			</p:panel>
		</h:form>
		<p:confirmDialog id="confirmaExclusao"
			message="Confirma exclusão do Estabelecimento?" header="Confirmação"
			severity="alert" widgetVar="confirmaExclusao" modal="true"
			appendTo="@(body)">
			<h:form>
				<p:commandButton id="confirmaBtn" value="Sim"
					onclick="confirmaExclusao.hide()"
					action="#{CadEstabelecimentoBean.excluir()}" ajax="false"
					icon="ui-icon-check">
				</p:commandButton>
				<p:commandButton id="recusaBtn" value="Não"
					onclick="confirmaExclusao.hide()" icon="ui-icon-close" />
			</h:form>
		</p:confirmDialog>

	</ui:define>
</ui:decorate>
</html>